API Documentation
Public Member Functions | List of all members
nkAstraeus::PbsMaterial Class Referencefinal

A Physically Based Shading material. More...

Inheritance diagram for nkAstraeus::PbsMaterial:
nkAstraeus::Material

Public Member Functions

 PbsMaterial ()
 
 ~PbsMaterial ()
 
virtual MATERIAL_TYPE getType () const override
 
nkMaths::Vector getLightDirection () const
 
nkMaths::Vector getLightColor () const
 
nkMaths::Vector getAlbedoColor () const
 
nkMaths::Vector getSpecularColor () const
 
nkMaths::Vector getEmissiveColor () const
 
nkMaths::Vector getEnvironmentColor () const
 
float getMetalness () const
 
float getRoughness () const
 
nkGraphics::TexturegetAlbedoTexture () const
 
nkGraphics::TexturegetSpecularTexture () const
 
nkGraphics::TexturegetEmissiveTexture () const
 
nkGraphics::TexturegetMetalnessTexture () const
 
nkGraphics::TexturegetRoughnessTexture () const
 
nkGraphics::TexturegetNormalMapTexture () const
 
nkGraphics::TexturegetEnvironmentTexture () const
 
nkGraphics::TexturegetIrradianceTexture () const
 
THREE_CHANNEL_PACK getAlbedoTextureChannels () const
 
THREE_CHANNEL_PACK getSpecularTextureChannels () const
 
THREE_CHANNEL_PACK getEmissiveTextureChannels () const
 
ONE_CHANNEL_PACK getMetalnessTextureChannels () const
 
ONE_CHANNEL_PACK getRoughnessTextureChannels () const
 
THREE_CHANNEL_PACK getNormalMapTextureChannels () const
 
THREE_CHANNEL_PACK getEnvironmentTextureChannels () const
 
THREE_CHANNEL_PACK getIrradianceTextureChannels () const
 
bool getEnvironmentTextureIsCubeByDefault () const
 
bool getIrradianceTextureIsCubeByDefault () const
 
void setLightDirection (const nkMaths::Vector &value)
 
void setLightColor (const nkMaths::Vector &value)
 
void setAlbedoColor (const nkMaths::Vector &value)
 
void setSpecularColor (const nkMaths::Vector &value)
 
void setEmissiveColor (const nkMaths::Vector &value)
 
void setEnvironmentColor (const nkMaths::Vector &value)
 
void setMetalness (float value)
 
void setRoughness (float value)
 
void setAlbedoTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setSpecularTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setEmissiveTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setMetalnessTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setRoughnessTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setNormalMapTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setEnvironmentTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB, bool prefilteredEnv=false)
 
void setIrradianceTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setEnvironmentTextureIsCubeByDefault (bool value)
 
void setIrradianceTextureIsCubeByDefault (bool value)
 
virtual bool load () override
 
virtual void unload () override
 
- Public Member Functions inherited from nkAstraeus::Material
 Material ()
 
virtual ~Material ()
 
nkMemory::StringView getName () const
 
nkGraphics::ShadergetShader () const
 
void setName (const nkMemory::StringView &value)
 

Detailed Description

A Physically Based Shading material.

This material aims to represent surfaces using physically plausible equations. It became a standard over the years, thanks to the limited number of parameters it requires, while offering pleasant results.

Constructor & Destructor Documentation

◆ PbsMaterial()

nkAstraeus::PbsMaterial::PbsMaterial ( )

Constructor.

◆ ~PbsMaterial()

nkAstraeus::PbsMaterial::~PbsMaterial ( )

Destructor.

Member Function Documentation

◆ getType()

virtual MATERIAL_TYPE nkAstraeus::PbsMaterial::getType ( ) const
overridevirtual
Returns
The real type of the material (MATERIAL_TYPE::PBS). See Material::getType().

Implements nkAstraeus::Material.

◆ getLightDirection()

nkMaths::Vector nkAstraeus::PbsMaterial::getLightDirection ( ) const
Returns
The currently set light direction.

◆ getLightColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getLightColor ( ) const
Returns
The currently set light color.

◆ getAlbedoColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getAlbedoColor ( ) const
Returns
The currently set constant albedo color.

◆ getSpecularColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getSpecularColor ( ) const
Returns
The currently set constant specular color.

◆ getEmissiveColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getEmissiveColor ( ) const
Returns
The currently set constant emissive color.

◆ getEnvironmentColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getEnvironmentColor ( ) const
Returns
The currently set constant environment color.

◆ getMetalness()

float nkAstraeus::PbsMaterial::getMetalness ( ) const
Returns
The currently set constant metalness value.

◆ getRoughness()

float nkAstraeus::PbsMaterial::getRoughness ( ) const
Returns
The currently set constant roughness value.

◆ getAlbedoTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getAlbedoTexture ( ) const
Returns
The currently set albedo texture.

◆ getSpecularTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getSpecularTexture ( ) const
Returns
The currently set specular texture.

◆ getEmissiveTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getEmissiveTexture ( ) const
Returns
The currently set emissive texture.

◆ getMetalnessTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getMetalnessTexture ( ) const
Returns
The currently set metalness texture.

◆ getRoughnessTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getRoughnessTexture ( ) const
Returns
The currently set roughness texture.

◆ getNormalMapTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getNormalMapTexture ( ) const
Returns
The currently set normal map texture.

◆ getEnvironmentTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getEnvironmentTexture ( ) const
Returns
The currently set environment texture.

◆ getIrradianceTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getIrradianceTexture ( ) const
Returns
The currently set irradiance texture.

◆ getAlbedoTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getAlbedoTextureChannels ( ) const
Returns
The currently used channels from the albedo texture.

◆ getSpecularTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getSpecularTextureChannels ( ) const
Returns
The currently used channels from the specular texture.

◆ getEmissiveTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getEmissiveTextureChannels ( ) const
Returns
The currently used channels from the emissive texture.

◆ getMetalnessTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getMetalnessTextureChannels ( ) const
Returns
The currently used channel from the metalness texture.

◆ getRoughnessTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getRoughnessTextureChannels ( ) const
Returns
The currently used channel from the roughness texture.

◆ getNormalMapTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getNormalMapTextureChannels ( ) const
Returns
The currently used channels from the normal map texture.

◆ getEnvironmentTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getEnvironmentTextureChannels ( ) const
Returns
The currently used channels from the environment texture.

◆ getIrradianceTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getIrradianceTextureChannels ( ) const
Returns
The currently used channels from the irradiance texture.

◆ getEnvironmentTextureIsCubeByDefault()

bool nkAstraeus::PbsMaterial::getEnvironmentTextureIsCubeByDefault ( ) const
Returns
Whether unloaded environment textures are expected as cube maps (true) or not (false).

◆ getIrradianceTextureIsCubeByDefault()

bool nkAstraeus::PbsMaterial::getIrradianceTextureIsCubeByDefault ( ) const
Returns
Whether unloaded irradiance textures are expected as cube maps (true) or not (false).

◆ setLightDirection()

void nkAstraeus::PbsMaterial::setLightDirection ( const nkMaths::Vector value)

Sets the light direction to use within the material. Currently, the only type of light supported is directional.

Parameters
valueThe direction of the light.
Remarks
This parameter is not used if an environment texture is set.

◆ setLightColor()

void nkAstraeus::PbsMaterial::setLightColor ( const nkMaths::Vector value)

Sets the color to use for the directional light when it is active.

Parameters
valueThe light color.
Remarks
This parameter is not used if an environment texture is set.

◆ setAlbedoColor()

void nkAstraeus::PbsMaterial::setAlbedoColor ( const nkMaths::Vector value)

Sets the constant albedo (diffuse) color to use on the whole surface.

Parameters
valueThe albedo color to use.

◆ setSpecularColor()

void nkAstraeus::PbsMaterial::setSpecularColor ( const nkMaths::Vector value)

Sets the constant specular (reflections) color to use on the whole surface.

Parameters
valueThe specular color to use.

◆ setEmissiveColor()

void nkAstraeus::PbsMaterial::setEmissiveColor ( const nkMaths::Vector value)

Sets the constant emissive color to use on the whole surface.

Parameters
valueThe emissive color to use.

◆ setEnvironmentColor()

void nkAstraeus::PbsMaterial::setEnvironmentColor ( const nkMaths::Vector value)

Sets a constant environment color. Can be seen as an ambient lighting.

Parameters
valueThe color to use.
Remarks
This parameter is not used if an environment texture is set.

◆ setMetalness()

void nkAstraeus::PbsMaterial::setMetalness ( float  value)

Sets the metalness of the material. Metalness is a factor between [0.0, 1.0], encoding how metallic the material should be. At 0, the material is dialectric, while at 1, it's fully metallic. Globally, at higher metallic level, the material will be more reflective.

Parameters
valueThe constant metalness to use on the whole surface.

◆ setRoughness()

void nkAstraeus::PbsMaterial::setRoughness ( float  value)

Sets the roughness of the material. Roughness is a factor between [0.0, 1.0], encoding how rough the material should be. At 0, the material is very smooth, while at 1, it is full of small rough patches. Low roughness values mean that the material will have clear reflections. As it goes higher, the reflections get blurrier.

Parameters
valueThe constant roughness to use on the whole surface.

◆ setAlbedoTexture()

void nkAstraeus::PbsMaterial::setAlbedoTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the albedo (diffuse) color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use as albedo.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setSpecularTexture()

void nkAstraeus::PbsMaterial::setSpecularTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the specular (reflections) color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use as specular.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setEmissiveTexture()

void nkAstraeus::PbsMaterial::setEmissiveTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the emissive color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use as emissive.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setMetalnessTexture()

void nkAstraeus::PbsMaterial::setMetalnessTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the metalness to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use as albedo.
channelThe texture channel the data is encoded in. Defaults to sample the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setRoughnessTexture()

void nkAstraeus::PbsMaterial::setRoughnessTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the roughness to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use as albedo.
channelThe texture channel the data is encoded in. Defaults to sample the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setNormalMapTexture()

void nkAstraeus::PbsMaterial::setNormalMapTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the normal map texture to use for normal mapping.

Parameters
valueThe texture to use as the normal map.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setEnvironmentTexture()

void nkAstraeus::PbsMaterial::setEnvironmentTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB,
bool  prefilteredEnv = false 
)

Sets the environment map to use. Giving a texture enables the Image Based Lighting functionality of the material for specular reflections. The texture can be either :

  • A 2D spherical map
  • A cube map

If the texture is unloaded when the material's load() method is called, the assumed texture type will be the one given by the setEnvironmentTextureIsCubeByDefault() function.

Parameters
valueThe texture to use as the environment.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
prefilteredEnvWhether the texture given is prefiltered (true) or not (false). If true, the material will use the split-sum optimization to improve performances.
Remarks
When changing the data channels or the prefiltered boolean, a material reload is needed. Updating a texture on the fly can be done with the material loaded. As the environment map is never considered as shared, this is true at all times.
To prefilter maps and benefit from the performances improvements, see PbsEnvMapFilter class.

◆ setIrradianceTexture()

void nkAstraeus::PbsMaterial::setIrradianceTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the irradiance map to use. Irradiance corresponds to the diffuse lighting from the environment, the average light incoming on the surface for any given direction. The texture can be either :

  • A 2D spherical map
  • A cube map

If the texture is unloaded when the material's load() method is called, the assumed texture type will be the one given by the setIrradianceTextureIsCubeByDefault() function.

Parameters
valueThe texture to use as the irradiance map.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded. As the irradiance map is never considered as shared, this is true at all times.

◆ setEnvironmentTextureIsCubeByDefault()

void nkAstraeus::PbsMaterial::setEnvironmentTextureIsCubeByDefault ( bool  value)

Sets whether the environment texture given should be expected as a cube map or not, when it is unloaded while the material is loading.

Parameters
valueWhether an unloaded texture should be expected as a cube map (true) or not (false).

◆ setIrradianceTextureIsCubeByDefault()

void nkAstraeus::PbsMaterial::setIrradianceTextureIsCubeByDefault ( bool  value)

Sets whether the irradiance texture given should be expected as a cube map or not, when it is unloaded while the material is loading.

Parameters
valueWhether an unloaded texture should be expected as a cube map (true) or not (false).

◆ load()

virtual bool nkAstraeus::PbsMaterial::load ( )
overridevirtual

◆ unload()

virtual void nkAstraeus::PbsMaterial::unload ( )
overridevirtual

The documentation for this class was generated from the following file: